<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function ajax_get(limit, page, cb) {
            let xhr = new XMLHttpRequest();
            let url = `http://jsonplaceholder.typicode.com/posts?_limit=${limit}&_page=${page}`;
            xhr.open("GET", url);
            xhr.send();
            xhr.addEventListener("readystatechange", function() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        let data = JSON.parse(xhr.responseText);
                        cb(data);
                    }
                }
            })
        }

        function render(data) {
            let div = document.createElement('div');
            data.forEach(function(ele) {
                div.innerHTML += `
                <div>${ele.id}</div>
                <div>${ele.title}</div>
                ---------------------
                <div>${ele.body}</div>
                `
            });
            document.body.appendChild(div)
        }


        ajax_get(12, 2, render)
    </script>
</body>

</html>